package com.itboye.sunsun.adapter;

import java.util.List;

import com.itboye.sunsun.R;
import com.itboye.sunsun.beans.CustomBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class CustomListViewAdapter extends BaseAdapter {



	private Context context;
	private List<CustomBean> list;
	
	

	public CustomListViewAdapter(Context context, List<CustomBean> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return list.get(position).getType();
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 3;
	}

	class ViewHolderDeal {

	}

	class ViewHolderSuccess {

	}

	class ViewHolderClose {

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolderDeal holdDeal = null;
		ViewHolderClose holdClose = null;
		ViewHolderSuccess holdSuccess = null;
		int type = getItemViewType(position);
		if (convertView == null) {
			switch (type) {
			case 1:
				convertView = LayoutInflater.from(context).inflate(
						R.layout.custom_listview_item_close, null);
				holdClose = new ViewHolderClose();
				convertView.setTag(holdClose);
				break;
			case 2:
				convertView = LayoutInflater.from(context).inflate(
						R.layout.custom_listview_item_success, null);
				holdSuccess = new ViewHolderSuccess();
				convertView.setTag(holdSuccess);
				break;
			case 3:
				convertView = LayoutInflater.from(context).inflate(
						R.layout.custom_listview_item_deal, null);
				holdDeal = new ViewHolderDeal();
				convertView.setTag(holdDeal);
				break;

			default:
				break;
			}
		} else {
			switch (type) {
			case 1:
				holdClose = (ViewHolderClose) convertView.getTag();
				break;
			case 2:
				holdSuccess = (ViewHolderSuccess) convertView.getTag();
				break;
			case 3:
				holdDeal = (ViewHolderDeal) convertView.getTag();
				break;

			default:
				break;
			}
		}

		return convertView;
	}

}